<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="lcy">
    <script src="jquery-3.1.1.js"></script>
    <title></title>
    <style>
        *{
            box-sizing: border-box;
        }
        ul,li,p,h2{
            padding: 0;
            margin: 0;
            list-style: none;
        }
        .brand{
            width: 312px;
            margin: 0 auto;
            border: 1px solid #ccc;
            box-shadow: 0 0 5px #ddd;
        }
        h2{
            height: 40px;
            line-height: 40px;
            text-align: center;
            font-size: 20px;
            color: #333;
            border-bottom: 2px solid #333;
        }
        ul{
            padding: 0 15px 10px 15px;
            overflow: hidden;
        }
        ul li{
            float: left;
            width: 120px;
            height: 75px;
            margin: 10px 10px 0 10px;
            position: relative;
        }
        li img{
            width: 120px;
            height: 75px;
            border: 1px solid #ccc;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 2;
        }
        li span{
            width: 120px;
            /*height: 75px;*/
            position: absolute;
            top: 37px;
            left: 0;
            border: 1px solid #ccc;
            background-color: #f93;
            color: white;
            text-align: center;
            line-height: 75px;
            height: 0;
            display: none;
            z-index: 1;
        }
    </style>
</head>
<body>
    <div class="brand">
        <h2>热门品牌推荐</h2>
        <ul>
            <li><a href="#"><img src="images/11.jpg" alt=""><span>精灵</span></a></li>
            <li><a href="#"><img src="images/22.jpg" alt=""><span>精灵</span></a></li>
            <li><a href="#"><img src="images/33.jpg" alt=""><span>精灵</span></a></li>
            <li><a href="#"><img src="images/44.jpg" alt=""><span>精灵</span></a></li>
            <li><a href="#"><img src="images/55.jpg" alt=""><span>精灵</span></a></li>
            <li><a href="#"><img src="images/66.jpg" alt=""><span>精灵</span></a></li>
            <li><a href="#"><img src="images/77.jpg" alt=""><span>精灵</span></a></li>
            <li><a href="#"><img src="images/88.jpg" alt=""><span>精灵</span></a></li>
        </ul>
    </div>
</body>
</html>
<script>
    $(function(){
        var ali=$('li');
        var aimg=$('img');
        var aspan=$('span');
        ali.each(function(index){
            $(this).mouseover(function(){
                // 鼠标进来图片高度变为0 当图片高度变为0后 紧接着让文字显示
                aimg.eq(index).stop();
                aspan.eq(index).stop();
                aimg.eq(index).css('z-index',1).animate({
                    height:0,
                    top:37,
                },80,function(){
                    // 图片进行隐藏
                    $(this).hide();
                    // 动画结束后 让文字显示
                    aspan.eq(index).show().css('z-index',2).animate({
                        height:75,
                        top:0,
                    },80);
                })
            })
            $(this).mouseout(function(){
                aimg.eq(index).stop();
                aspan.eq(index).stop();
                // 鼠标出去 文字高度改为0 紧接着显示图片
                aspan.eq(index).css('z-index',2).animate({
                    top:37,
                    height:0,
                },80,function(){
                    $(this).hide();
                    aimg.eq(index).show().css('z-index',2).animate({
                        height:75,
                        top:0,
                    },80)
                })
            })
        })




    })
</script>